package com.wolfeyes.framework.alipay.config;

import java.io.FileWriter;
import java.io.IOException;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import lombok.Data;

/**
 * @description 禁止硬编码，严禁在`生产项目`当中大量写死的硬编码（Hard code）
 * @author yanyljava
 * @email yanyljava@qq.com
 * @create 2021-09-12 22:14
 */
@Data
@Component
@ConfigurationProperties(prefix = "alipay")
public class AlipayConfig {
	
	// 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
	//public static String app_id = "2016091800540620";
	//public static String app_id = "2021000118606840";
	private String appId;

	// 商户私钥，您的PKCS8格式RSA2私钥
	//public static String merchant_private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCW09PYhUqDMaGFJe/ggB8Y/WFbt+UMNkRNaDhhAyzldJLJiUvw6wGEMLGdJ1eRVAg3RNJ8NOdOr0Z+m6Mlai6S+1VqUPa68CZxC7AIfYvcrkeGaFcxWl3zwVZmUfC8LxuPNpDu6G1KX+DRBlkNzCGw+rMYZXrXh657VEyrth/WtMDAB4/d12mHlBRueZr8scrbacOO/V7f8i+5AqkAqlxz0+zT42dVkQiJNLAOI+gjRKUwzRgUksSJU869o3At8kR2Xm/8tKYvbKrv1Er4/K1HcgdkYQ6K1lTZQm7bMAi0M7xsEcXgjK4jQV83yKGgyPfi7MsaPKLsowCCtTtpC/ALAgMBAAECggEAcNe6v1u6C72uInfnqAczPPcVSBGlhCV1pJQ82hgOFv3IdJAMCQtJ7ySfPfyZP1mna/JJqDPMesoX69F1liCDB+SSWyCH+ASEPj+ITFHhuhGJ4b1evsXlVOFpStQzUBfOfq9Mb/HlEqf5A2nEZtY6vrZSGAaUiXwxxoOjeTShTXhy/FGqbyaZe1LKuTZwVtZKaWXXao24akxwcFluHsswstHMBZdRisEfp5ny42jXH2l5dp5Uy+wgupYloxKPeBUgGCN911TaKOdaY2p5rLwVDr6938qXFhIKDNIXviiOAFt0wHhr3EyrE2Q9YgBSIS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ZIq1rzv75TSIxKRPGB2UNU8+lA5AoGBAIPs/gJSfLFezrATp6Xodg3wr5xWV4gATi05dR1MiuzHp0McPc6RjkDAoLAsyM/lzTO1RIvBW/+J/cLVYtSJcDvi9TFOtjYe5IE0MFlpgx1YRRfTDLx6WGqsGAaEioxzB0qt6cqOX81OyneUzvM4SNY6zagag3V9z4O82AQZqcRFAoGBAI64cTycA7p5JD2aJGfAXkDnIxRxu/ekw+RGhW02w5MUeu2L9wyCfyPgdH/kotKQ2lhOur/kHyALjT8GY8mP0di86mpJqldmyYMfX1jSGa9i073w6bL4RX76AruEpZbqTnE+kMJb3FbdPZZ+dWW+Wf8JoCN995uIE+6XF8lglwOl";
	private String merchantPrivateKey;
	
	// 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
	//public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0Y6S4f1JpU6wdzpUnnaAdupvRcv+pwGnfUS8HzvRidMzmBOLmbRsF1phdh7XshOeHCYk3AEngyw3qFFSM+IDxOkbRRWidAoryKyj9UFEBx4fEGVBTCNR5NSH3D/+y+BJw0pSPFMnWPN5vkKx0G0un4GRakvff7hRTWe3piGmoP8TH7lapVb5isKXiTNhm56bX/55skXndCFfqhMjeUaFOBc6yQvBjAJNLrEk5NiGQbXgiKf0QfDhcAX8w2RvcA4uKJ77PGvmRF55OfZ1ZLMLmCaUr7gevLrUJR012NljREUIJqm+OMC4g/oHlRaDhmvADehlYqd/Vyz8vxIlm8pmbQIDAQAB";
	//public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsTOyYgf+r55FnMGKDAlvT+Kfg+Js2k+SCzeFSVHCKK4QNpc01Z3xuhGnnIfctYY+jDOh/1LxtoKzf4+m8NiqLfgnnEQUfVMguEJMsL7uQr3dNQc5PosApvonV5piXrbk0tAJ86KxBoARQdK1AYVl93S9AmwHaKZBLGHtPk7+1aVYYFlZlkkUbhPnxZttHng7M12GmfarnFnXdAYbz9qhkibOx72b3YsisxaA7t7BuodleNXhwSOfFiu+lybODqzezM9+9BlsdV94W7ITnb5nV0i1V4ZLTghYnlT1SyWh9mP3b77RwDvwYm53y0O72iX0XPSWNWBW42FqK88/3ggy+wIDAQAB";
	private String alipayPublicKey;

	// 支付宝网关-（请求网关 固定 serverUrl 或者：gatewayUrl）
	//public static String gatewayUrl = "https://openapi.alipay.com/gateway.do";
	//public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
	private String gatewayUrl;
	
	// 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	//public static String notify_url = "http://localhost:8083/alipay/notify_url";
	private String notifyUrl;

	// 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
//	public static String return_url = "http://localhost:8080/alipay/return_url.jsp";
	//public static String return_url = "http://localhost:8083/alipay/return_url";
	private String returnUrl;
	
	// 支付处理成功后的回调地址(前端Vue项目路径)
	private String callBackUrl;
	
	// 签名方式
	//public static String sign_type = "RSA2";
	private String signType;

	// 返回格式
	//public static String format = "json";
	private String format;
	// 字符编码格式
	//public static String charset = "utf-8";
	private String charset;

	// 日志存储根路径
	//public static String log_path = "C:\\";
	private String log_path;

	/**
	 * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
	 * @param sWord 要写入日志里的文本内容
	 */
	//public static void logResult(String sWord) {
	public void logResult(String sWord) {
		FileWriter writer = null;
		try {
			writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
			writer.write(sWord);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (writer != null) {
				try {
					writer.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

}

